package com.lx.gulimall.ware.exception;

import com.lx.common.exception.BizCodeEnum;
import com.lx.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lixun Email:lx3027@126.com
 * @create 2021-07-08 9:10
 *
 *  集中处理所有异常
 */
@Slf4j
//@ResponseBody
//@ControllerAdvice(basePackages = "com.lx.gulimall.product.controller")

@RestControllerAdvice(basePackages = "com.lx.gulimall.ware.controller")
public class GulimallExceptionControllerAdvice {

    @ExceptionHandler(value = PurchaseDetailException.class)
    public R handleException(PurchaseDetailException throwable){
        return R.error(BizCodeEnum.PLEASE_SELECT_VALID_PURCHASE_ORDER.getCode(),BizCodeEnum.PLEASE_SELECT_VALID_PURCHASE_ORDER.getMsg());
    }

}
